package com.augurit.gzcgwsp.jzfqwczz.common.convert;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.dozer.DozerBeanMapper;

import com.augurit.gzcgwsp.jzfqwczz.common.entity.YwYnJzfqwczzXckc;
import com.augurit.gzcgwsp.jzfqwczz.common.web.form.YwYnJzfqwczzXckcForm;

public class YwYnJzfqwczzXckcConvertor {
	public static YwYnJzfqwczzXckcForm convertVoToForm(YwYnJzfqwczzXckc entity) {
		if (entity == null) return null;
		
		return new DozerBeanMapper().map(entity, YwYnJzfqwczzXckcForm.class);
	}
	
	public static void convertFormToVo(YwYnJzfqwczzXckcForm form, YwYnJzfqwczzXckc entity) {
				
		if(form.getId() != null)
			entity.setId(form.getId());
		if(form.getDmywgb() != null && form.getDmywgb().trim().length() > 0)
			entity.setDmywgb(form.getDmywgb());
		if(form.getHxtsydbg() != null && form.getHxtsydbg().trim().length() > 0)
			entity.setHxtsydbg(form.getHxtsydbg());
		if(form.getSgxcxdyjdbg() != null && form.getSgxcxdyjdbg().trim().length() > 0)
			entity.setSgxcxdyjdbg(form.getSgxcxdyjdbg());
		if(form.getZfll() != null && form.getZfll().trim().length() > 0)
			entity.setZfll(form.getZfll());
		if(form.getSgmj() != null && form.getSgmj().trim().length() > 0)
			entity.setSgmj(form.getSgmj());
		if(form.getTzqk() != null && form.getTzqk().trim().length() > 0)
			entity.setTzqk(form.getTzqk());
		if(form.getNeedKcsj() != null && form.getNeedKcsj().trim().length() > 0)
			entity.setNeedKcsj(form.getNeedKcsj());
		if(form.getKcsj() != null)
			entity.setKcsj(form.getKcsj());
		if(form.getKcry() != null && form.getKcry().trim().length() > 0)
			entity.setKcry(form.getKcry());
		if(form.getYwId() != null)
			entity.setYwId(form.getYwId());
		if(form.getTplcode() != null && form.getTplcode().trim().length() > 0)
			entity.setTplcode(form.getTplcode());
		
	}
	
	public static List<YwYnJzfqwczzXckcForm> convertVoListToFormList(List<YwYnJzfqwczzXckc> ywYnJzfqwczzXckcList) {
		if(ywYnJzfqwczzXckcList != null && ywYnJzfqwczzXckcList.size() > 0) {
			List<YwYnJzfqwczzXckcForm> ywYnJzfqwczzXckcFormList = new ArrayList<YwYnJzfqwczzXckcForm>();
			for(int i=0; i<ywYnJzfqwczzXckcList.size(); i++) {
				ywYnJzfqwczzXckcFormList.add(convertVoToForm(ywYnJzfqwczzXckcList.get(i)));
			}
			return ywYnJzfqwczzXckcFormList;
		}
		return null;
	}
	
	public static List<YwYnJzfqwczzXckc> convertFormListToVoList(List<YwYnJzfqwczzXckcForm> ywYnJzfqwczzXckcFormList) {
		if(ywYnJzfqwczzXckcFormList != null && ywYnJzfqwczzXckcFormList.size() > 0) {
			List<YwYnJzfqwczzXckc> ywYnJzfqwczzXckcList = new ArrayList<YwYnJzfqwczzXckc>();
			for(int i=0; i<ywYnJzfqwczzXckcFormList.size(); i++) {
				YwYnJzfqwczzXckc ywYnJzfqwczzXckc = new YwYnJzfqwczzXckc();
				convertFormToVo(ywYnJzfqwczzXckcFormList.get(i), ywYnJzfqwczzXckc);
				ywYnJzfqwczzXckcList.add(ywYnJzfqwczzXckc);
			}
			return ywYnJzfqwczzXckcList;
		}
		return null;
	}
}